macro(reflang_test TEST REGEX)
	message(STATUS "Generating test target: ${TEST}")

	set(INPUT "${TEST}.src.hpp")
	set(OUT_HPP "${TEST}.gen.hpp")
	set(OUT_CPP "${TEST}.gen.cpp")
	set(SOURCE "${TEST}.test.cpp")

	add_custom_command(
		OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${OUT_HPP}"
		COMMAND ${CMAKE_COMMAND}
		ARGS
			-DINPUT=${INPUT}
			-DOUT_HPP=${OUT_HPP}
			-DOUT_CPP=${OUT_CPP}
			-DGEN=$<TARGET_FILE:reflang>
			-DREGEX="${REGEX}"
			-P ${CMAKE_SOURCE_DIR}/cmake/runtest.cmake
		WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

	add_custom_command(
		OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${OUT_CPP}"
		COMMAND echo "Pretending to generate ${OUT_CPP} -- this is generated by ${OUT_HPP} rule.")

	add_executable(
		${TEST}
		${SOURCE}
		${INPUT}
		"${CMAKE_CURRENT_SOURCE_DIR}/${OUT_HPP}"
		"${CMAKE_CURRENT_SOURCE_DIR}/${OUT_CPP}")
	target_link_libraries(${TEST} libreflang)

	add_test("${TEST}-test" ${TEST})

	set_property(TARGET ${TEST} PROPERTY FOLDER "tests")
endmacro()

add_subdirectory(lib)

add_subdirectory(enum)
add_subdirectory(function)
add_subdirectory(class)
